﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.Revit.MEP.Electric.Calculator;

namespace YArchitech.Revit.MEP.Calculator
{
	public partial class DlgIllCalMain : System.Windows.Forms.Form
	{
		public DlgIllCalMain(UIApplication uiapplication)
		{
			this.uiApp = uiapplication;
			this.doc = this.uiApp.ActiveUIDocument.ActiveView.Document;
			this.activeView = this.doc.ActiveView;
			this.InitializeComponent();
		}

		private void DlgIllCalMain_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.CreateDefaultTabPage();
		}

		private void DlgIllCalMain_Shown(object sender, EventArgs e)
		{
			this.ReferenceTagPageData();
		}

		private void tabLevels_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.ReferenceTagPageData();
		}

		private void ReferenceTagPageData()
		{
			DlgIllCalData dlgIllCalData = this.tabLevels.SelectedTab.Controls["DlgIllCalData"] as DlgIllCalData;
			dlgIllCalData.RefreshDataGridView();
			if (dlgIllCalData.dgvRoomData.Rows.Count > 0)
			{
				int index = dlgIllCalData.dgvRoomData.Rows.Count - 1;
				dlgIllCalData.dgvRoomData.CurrentCell = dlgIllCalData.dgvRoomData.Rows[index].Cells[0];
				dlgIllCalData.RefreshCurrentLampParam();
				dlgIllCalData.RefreshCurrentLightSourceParam();
				dlgIllCalData.RefreshCurrentCalData();
			}
		}

		private void CreateDefaultTabPage()
		{
			if (this.tabLevels.TabPages[this.activeView.GenLevel.Name] == null)
			{
				this.CreateTabPage(this.activeView.GenLevel.Name);
			}
		}

		private void CreateTabPage(string name)
		{
			TabPage tabPage = new TabPage();
			tabPage.Text = name;
			tabPage.Name = name;
			DlgIllCalData dlgIllCalData = new DlgIllCalData(this.uiApp);
			dlgIllCalData.Name = "DlgIllCalData";
			dlgIllCalData.TopLevel = false;
			tabPage.Controls.Add(dlgIllCalData);
			dlgIllCalData.Show();
			this.tabLevels.TabPages.Add(tabPage);
		}

		private void tsbSelRoomTag_Click(object sender, EventArgs e)
		{
			this.selectionMethod = 0;
			base.DialogResult = DialogResult.OK;
		}

		private void tsbSelRoomTags_Click(object sender, EventArgs e)
		{
			this.selectionMethod = 1;
			base.DialogResult = DialogResult.OK;
		}

		private void tsbSelAllRoomTags_Click(object sender, EventArgs e)
		{
			this.selectionMethod = 2;
			base.DialogResult = DialogResult.OK;
		}

		private void tsbDelRoomTag_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show("确定要删除房间信息吗?", "盈建科提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
			{
				return;
			}
			DlgIllCalData dlgIllCalData = this.tabLevels.SelectedTab.Controls["DlgIllCalData"] as DlgIllCalData;
			if (dlgIllCalData.dgvRoomData.SelectedRows.Count == 1)
			{
				int index = dlgIllCalData.dgvRoomData.CurrentRow.Index;
				if (index >= 0)
				{
					dlgIllCalData.illCalDataSet.listIllCalData.RemoveAt(index);
					for (int i = 0; i < dlgIllCalData.illCalDataSet.listIllCalData.Count; i++)
					{
						dlgIllCalData.illCalDataSet.listIllCalData[i].roomData.RoomIndex = i + 1;
					}
					dlgIllCalData.RefreshDataGridView();
					if (dlgIllCalData.illCalDataSet.listIllCalData.Count > 0)
					{
						int index2 = dlgIllCalData.dgvRoomData.Rows.Count - 1;
						dlgIllCalData.dgvRoomData.CurrentCell = dlgIllCalData.dgvRoomData.Rows[index2].Cells[0];
						dlgIllCalData.RefreshCurrentLampParam();
						dlgIllCalData.RefreshCurrentLightSourceParam();
						dlgIllCalData.RefreshCurrentCalData();
					}
				}
				dlgIllCalData.cmbCeilingFactor.Visible = false;
				dlgIllCalData.cmbWallDownFactor.Visible = false;
				dlgIllCalData.cmbWallUpFactor.Visible = false;
				dlgIllCalData.cmbGroundFactor.Visible = false;
				dlgIllCalData.btnIllAndPower.Visible = false;
			}
			if (dlgIllCalData.dgvRoomData.SelectedRows.Count == 0)
			{
				this.tsbDelRoomTag.Enabled = false;
			}
		}

		private void tsbLightLibrary_Click(object sender, EventArgs e)
		{
			new DlgLightSourceLibrary().ShowDialog();
		}

		private void tsbQuit_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void tsbMultiModify_Click(object sender, EventArgs e)
		{
			DlgIllCalData dlgIllCalData = this.tabLevels.SelectedTab.Controls["DlgIllCalData"] as DlgIllCalData;
			using (DlgColumnModify dlgColumnModify = new DlgColumnModify())
			{
				if (dlgColumnModify.ShowDialog() == DialogResult.OK)
				{
					foreach (object obj in dlgIllCalData.dgvRoomData.SelectedRows)
					{
						int index = ((DataGridViewRow)obj).Index;
						RoomData roomData = dlgIllCalData.illCalDataSet.listIllCalData.ElementAt(index).roomData;
						double roomHeight = roomData.RoomHeight;
						double workHeight = roomData.WorkHeight;
						double installHeight = roomData.InstallHeight;
						double num = 0.0;
						double num2 = 0.0;
						double num3 = 0.0;
						Dictionary<string, string> dicRoomData = dlgColumnModify.DicRoomData;
						foreach (string text in dicRoomData.Keys)
						{
							uint num4 = 0;//<PrivateImplementationDetails>.ComputeStringHash(text);
							if (num4 <= 2434120127u)
							{
								if (num4 <= 1180674478u)
								{
									if (num4 != 343041595u)
									{
										if (num4 == 1180674478u)
										{
											if (text == "WindowFactor")
											{
												roomData.WindowFactor = Convert.ToDouble(dicRoomData[text]);
											}
										}
									}
									else if (text == "InstallHeight")
									{
										num3 = Convert.ToDouble(dicRoomData[text]);
									}
								}
								else if (num4 != 1194260590u)
								{
									if (num4 != 1513059907u)
									{
										if (num4 == 2434120127u)
										{
											if (text == "Lpd")
											{
												roomData.Lpd = Convert.ToDouble(dicRoomData[text]);
											}
										}
									}
									else if (text == "CeilingFactor")
									{
										roomData.CeilingFactor = Convert.ToDouble(dicRoomData[text]);
									}
								}
								else if (text == "FloorFactor")
								{
									roomData.FloorFactor = Convert.ToDouble(dicRoomData[text]);
								}
							}
							else if (num4 <= 3089825177u)
							{
								if (num4 != 2803669030u)
								{
									if (num4 == 3089825177u)
									{
										if (text == "RoomHeight")
										{
											num = Convert.ToDouble(dicRoomData[text]);
										}
									}
								}
								else if (text == "Lux")
								{
									roomData.Lux = Convert.ToDouble(dicRoomData[text]);
								}
							}
							else if (num4 != 3152175891u)
							{
								if (num4 != 3488416891u)
								{
									if (num4 == 3511743878u)
									{
										if (text == "WallDownFactor")
										{
											roomData.WallDownFactor = Convert.ToDouble(dicRoomData[text]);
										}
									}
								}
								else if (text == "WorkHeight")
								{
									num2 = Convert.ToDouble(dicRoomData[text]);
								}
							}
							else if (text == "WallUpFactor")
							{
								roomData.WallUpFactor = Convert.ToDouble(dicRoomData[text]);
							}
						}
						if (num == 0.0 && num3 != 0.0 && num2 != 0.0)
						{
							if (roomHeight >= num3)
							{
								roomData.InstallHeight = num3;
								roomData.WorkHeight = num2;
							}
						}
						else if (num != 0.0 && num3 == 0.0 && num2 != 0.0)
						{
							if (installHeight <= num && installHeight >= num2)
							{
								roomData.RoomHeight = num;
								roomData.WorkHeight = num2;
							}
						}
						else if (num != 0.0 && num3 != 0.0 && num2 == 0.0)
						{
							if (workHeight <= num3)
							{
								roomData.RoomHeight = num;
								roomData.InstallHeight = num3;
							}
						}
						else if (num != 0.0 && num3 == 0.0 && num2 == 0.0)
						{
							if (installHeight <= num)
							{
								roomData.RoomHeight = num;
							}
						}
						else if (num == 0.0 && num3 != 0.0 && num2 == 0.0)
						{
							if (roomHeight >= num3 && workHeight <= num3)
							{
								roomData.InstallHeight = num3;
							}
						}
						else if (num == 0.0 && num3 == 0.0 && num2 != 0.0)
						{
							if (installHeight >= num2)
							{
								roomData.WorkHeight = num2;
							}
						}
						else if (num != 0.0 && num3 != 0.0 && num2 != 0.0)
						{
							roomData.RoomHeight = num;
							roomData.WorkHeight = num2;
							roomData.InstallHeight = num3;
						}
					}
					dlgIllCalData.RefreshDataGridView();
					int index2 = dlgIllCalData.dgvRoomData.CurrentRow.Index;
					dlgIllCalData.illCalDataSet.activeIllCalData = dlgIllCalData.illCalDataSet.listIllCalData.ElementAt(index2);
				}
			}
		}

		private void tsbSave_Click(object sender, EventArgs e)
		{
			this.SaveXML();
		}

		private void tsbLoad_Click(object sender, EventArgs e)
		{
			if (!this.ReadXML())
			{
				return;
			}
			foreach (object obj in this.tabLevels.TabPages)
			{
				DlgIllCalData dlgIllCalData = ((TabPage)obj).Controls["DlgIllCalData"] as DlgIllCalData;
				dlgIllCalData.InitLampType();
				dlgIllCalData.InitMaintenanceFactor();
				dlgIllCalData.RefreshDataGridView();
			}
			DlgIllCalData dlgIllCalData2 = this.tabLevels.SelectedTab.Controls["DlgIllCalData"] as DlgIllCalData;
			dlgIllCalData2.RefreshDataGridView();
			if (dlgIllCalData2.illCalDataSet.listIllCalData.Count > 0)
			{
				int index = dlgIllCalData2.dgvRoomData.Rows.Count - 1;
				dlgIllCalData2.dgvRoomData.CurrentCell = dlgIllCalData2.dgvRoomData.Rows[index].Cells[0];
				dlgIllCalData2.RefreshCurrentLampParam();
				dlgIllCalData2.RefreshCurrentLightSourceParam();
				dlgIllCalData2.RefreshCurrentCalData();
			}
		}

		private void SaveXML()
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = "*.ill|*.ill";
			saveFileDialog.RestoreDirectory = true;
			string text = this.doc.Title;
			if (text.Contains(".rvt"))
			{
				text = text.Substring(0, text.IndexOf(".rvt"));
			}
			saveFileDialog.FileName = text;
			if (saveFileDialog.ShowDialog() != DialogResult.OK)
			{
				return;
			}
			string fileName = saveFileDialog.FileName;
			XmlDocument xmlDocument = new XmlDocument();
			XmlDeclaration newChild = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);
			xmlDocument.AppendChild(newChild);
			XmlElement newChild2 = xmlDocument.CreateElement("Boot");
			xmlDocument.AppendChild(newChild2);
			foreach (object obj in this.tabLevels.TabPages)
			{
				TabPage tabPage = (TabPage)obj;
				DlgIllCalData dlgIllCalData = tabPage.Controls["DlgIllCalData"] as DlgIllCalData;
				if (dlgIllCalData.illCalDataSet.listIllCalData.Count > 0)
				{
					XmlNode xmlNode = xmlDocument.SelectSingleNode("Boot");
					XmlElement xmlElement = xmlDocument.CreateElement("DataItems");
					xmlElement.SetAttribute("Level", tabPage.Name);
					for (int i = 0; i < dlgIllCalData.illCalDataSet.listIllCalData.Count; i++)
					{
						XmlElement xmlElement2 = xmlDocument.CreateElement("DataItem");
						IllCalData illCalData = dlgIllCalData.illCalDataSet.listIllCalData.ElementAt(i);
						xmlElement2.SetAttribute("CalState", ((int)illCalData.roomData.CalState).ToString());
						xmlElement2.SetAttribute("RoomIndex", illCalData.roomData.RoomIndex.ToString());
						xmlElement2.SetAttribute("RoomNumber", illCalData.roomData.RoomNumber.ToString());
						xmlElement2.SetAttribute("RoomName", illCalData.roomData.RoomName.ToString());
						xmlElement2.SetAttribute("RoomArea", illCalData.roomData.RoomArea.ToString());
						xmlElement2.SetAttribute("RoomHeight", illCalData.roomData.RoomHeight.ToString());
						xmlElement2.SetAttribute("WorkHeight", illCalData.roomData.WorkHeight.ToString());
						xmlElement2.SetAttribute("InstallHeight", illCalData.roomData.InstallHeight.ToString());
						xmlElement2.SetAttribute("CeilingFactor", illCalData.roomData.CeilingFactor.ToString());
						xmlElement2.SetAttribute("WallUpFactor", illCalData.roomData.WallUpFactor.ToString());
						xmlElement2.SetAttribute("WallDownFactor", illCalData.roomData.WallDownFactor.ToString());
						xmlElement2.SetAttribute("FloorFactor", illCalData.roomData.FloorFactor.ToString());
						xmlElement2.SetAttribute("WindowArea", illCalData.roomData.WindowArea.ToString());
						xmlElement2.SetAttribute("WindowFactor", illCalData.roomData.WindowFactor.ToString());
						xmlElement2.SetAttribute("Lux", illCalData.roomData.Lux.ToString());
						xmlElement2.SetAttribute("Lpd", illCalData.roomData.Lpd.ToString());
						xmlElement2.SetAttribute("RoomPerimeter", illCalData.roomData.RoomPerimeter.ToString());
						xmlElement2.SetAttribute("WallPerimeter", illCalData.roomData.WallPerimeter.ToString());
						if (illCalData.roomData.RoomTagID != null)
						{
							xmlElement2.SetAttribute("RoomTagID", illCalData.roomData.RoomTagID.ToString());
						}
						else
						{
							xmlElement2.SetAttribute("RoomTagID", "");
						}
						xmlElement2.SetAttribute("GUID", illCalData.lampData.GUID.ToString());
						xmlElement2.SetAttribute("LampType", illCalData.lampData.Type.ToString());
						xmlElement2.SetAttribute("Name", illCalData.lampData.Name.ToString());
						xmlElement2.SetAttribute("Spec", illCalData.lampData.Spec.ToString());
						xmlElement2.SetAttribute("MaintenanceFactor", illCalData.lampData.MaintenanceFactor.ToString());
						xmlElement2.SetAttribute("UseFactor", illCalData.lampData.UseFactor.ToString("0.00"));
						xmlElement2.SetAttribute("BallastPower", illCalData.lampData.BallastPower.ToString());
						xmlElement2.SetAttribute("LightSourceType", illCalData.lightSourceData.Type.ToString());
						xmlElement2.SetAttribute("LightSourceName", illCalData.lightSourceData.Name.ToString());
						xmlElement2.SetAttribute("Model", illCalData.lightSourceData.Model.ToString());
						xmlElement2.SetAttribute("Number", illCalData.lightSourceData.Number.ToString());
						xmlElement2.SetAttribute("Power", illCalData.lightSourceData.Power.ToString());
						xmlElement2.SetAttribute("LuminousFlux", illCalData.lightSourceData.LuminousFlux.ToString());
						xmlElement2.SetAttribute("LampNumber", illCalData.calResultData.LampNumber.ToString());
						xmlElement2.SetAttribute("LuxResult", illCalData.calResultData.Lux.ToString());
						xmlElement2.SetAttribute("LuxChecked", ((int)illCalData.calResultData.LuxChecked).ToString());
						xmlElement2.SetAttribute("LpdResult", illCalData.calResultData.Lpd.ToString());
						xmlElement2.SetAttribute("LpdEx", illCalData.calResultData.LpdEx.ToString());
						xmlElement2.SetAttribute("LpdChecked", ((int)illCalData.calResultData.LpdChecked).ToString());
						xmlElement.AppendChild(xmlElement2);
					}
					xmlNode.AppendChild(xmlElement);
				}
			}
			xmlDocument.Save(fileName);
		}

		private bool ReadXML()
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			openFileDialog.Filter = "*.ill|*.ill|所有文件(*.*)|*.*";
			if (openFileDialog.ShowDialog() != DialogResult.OK)
			{
				return false;
			}
			string fileName = openFileDialog.FileName;
			XmlDocument xmlDocument = new XmlDocument();
			try
			{
				xmlDocument.Load(fileName);
			}
			catch (Exception)
			{
				MessageBox.Show("未知的数据文件，请检查文件内容！", "盈建科提示");
				return false;
			}
			List<AnnotationSymbol> list = new List<AnnotationSymbol>();
			foreach (Element element in ((IEnumerable<Element>)Common.GetElementByCategory(this.doc, BuiltInCategory.OST_GenericAnnotation)))
			{
				AnnotationSymbol annotationSymbol = element as AnnotationSymbol;
				if (annotationSymbol != null && annotationSymbol.Name == "房间照明标记")
				{
					list.Add(annotationSymbol);
				}
			}
			foreach (object obj in xmlDocument.SelectNodes("Boot/DataItems/DataItem/@RoomTagID"))
			{
				XmlNode xmlNode = (XmlNode)obj;
				bool flag = false;
				string value = xmlNode.Value;
				using (List<AnnotationSymbol>.Enumerator enumerator3 = list.GetEnumerator())
				{
					while (enumerator3.MoveNext())
					{
						if (enumerator3.Current.Id.ToString() == value)
						{
							flag = true;
						}
					}
				}
				if (!flag)
				{
					MessageBox.Show("加载失败，请检查是否为当前项目的数据文件或项目已改变！", "盈建科提示");
					return false;
				}
			}
			XmlNode documentElement = xmlDocument.DocumentElement;
			List<string> list2 = new List<string>();
			foreach (object obj2 in documentElement.ChildNodes)
			{
				XmlNode xmlNode2 = (XmlNode)obj2;
				if (xmlNode2.Name == "DataItems")
				{
					list2.Add(xmlNode2.Attributes["Level"].Value);
				}
			}
			if (list2.Count <= 0)
			{
				MessageBox.Show("加载数据文件的内容为空！", "盈建科提示");
				return false;
			}
			foreach (string text in list2)
			{
				bool flag2 = false;
				foreach (object obj3 in this.tabLevels.TabPages)
				{
					TabPage tabPage = (TabPage)obj3;
					if (tabPage.Name == text)
					{
						flag2 = true;
						(tabPage.Controls["DlgIllCalData"] as DlgIllCalData).illCalDataSet.listIllCalData.Clear();
					}
				}
				if (!flag2)
				{
					this.CreateTabPage(text);
				}
			}
			foreach (object obj4 in this.tabLevels.TabPages)
			{
				TabPage tabPage2 = (TabPage)obj4;
				bool flag3 = false;
				foreach (string b in list2)
				{
					if (tabPage2.Name == b)
					{
						flag3 = true;
					}
				}
				if (!flag3)
				{
					this.tabLevels.TabPages.Remove(tabPage2);
				}
			}
			foreach (object obj5 in documentElement.ChildNodes)
			{
				XmlNode xmlNode3 = (XmlNode)obj5;
				foreach (object obj6 in this.tabLevels.TabPages)
				{
					TabPage tabPage3 = (TabPage)obj6;
					if (xmlNode3.Name == "DataItems" && xmlNode3.Attributes["Level"].Value == tabPage3.Name)
					{
						DlgIllCalData dlgIllCalData = tabPage3.Controls["DlgIllCalData"] as DlgIllCalData;
						foreach (object obj7 in xmlNode3.ChildNodes)
						{
							XmlNode xmlNode4 = (XmlNode)obj7;
							IllCalData illCalData = new IllCalData();
							if (xmlNode4.Name == "DataItem")
							{
								for (int i = 0; i < xmlNode4.Attributes.Count; i++)
								{
									string localName = xmlNode4.Attributes[i].LocalName;
									uint num = 0;//<PrivateImplementationDetails>.ComputeStringHash(localName);
									if (num <= 2392788958u)
									{
										if (num <= 1180674478u)
										{
											if (num <= 703418188u)
											{
												if (num <= 286595226u)
												{
													if (num != 266367750u)
													{
														if (num == 286595226u)
														{
															if (localName == "LampNumber")
															{
																illCalData.calResultData.LampNumber = Convert.ToInt32(xmlNode4.Attributes[i].Value);
															}
														}
													}
													else if (localName == "Name")
													{
														illCalData.lampData.Name = Convert.ToString(xmlNode4.Attributes[i].Value);
													}
												}
												else if (num != 343041595u)
												{
													if (num == 703418188u)
													{
														if (localName == "GUID")
														{
															string g = Convert.ToString(xmlNode4.Attributes[i].Value);
															Guid guid = new Guid(g);
															illCalData.lampData.GUID = guid;
														}
													}
												}
												else if (localName == "InstallHeight")
												{
													illCalData.roomData.InstallHeight = Convert.ToDouble(xmlNode4.Attributes[i].Value);
												}
											}
											else if (num <= 759508270u)
											{
												if (num != 758798527u)
												{
													if (num == 759508270u)
													{
														if (localName == "RoomIndex")
														{
															illCalData.roomData.RoomIndex = Convert.ToInt32(xmlNode4.Attributes[i].Value);
														}
													}
												}
												else if (localName == "UseFactor")
												{
													illCalData.lampData.UseFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
												}
											}
											else if (num != 1075249265u)
											{
												if (num != 1127456135u)
												{
													if (num == 1180674478u)
													{
														if (localName == "WindowFactor")
														{
															illCalData.roomData.WindowFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
														}
													}
												}
												else if (localName == "RoomNumber")
												{
													illCalData.roomData.RoomNumber = Convert.ToString(xmlNode4.Attributes[i].Value);
												}
											}
											else if (localName == "RoomPerimeter")
											{
												illCalData.roomData.RoomPerimeter = Convert.ToDouble(xmlNode4.Attributes[i].Value);
											}
										}
										else if (num <= 1642719936u)
										{
											if (num <= 1198798012u)
											{
												if (num != 1194260590u)
												{
													if (num == 1198798012u)
													{
														if (localName == "WindowArea")
														{
															illCalData.roomData.WindowArea = Convert.ToDouble(xmlNode4.Attributes[i].Value);
														}
													}
												}
												else if (localName == "FloorFactor")
												{
													illCalData.roomData.FloorFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
												}
											}
											else if (num != 1369251375u)
											{
												if (num != 1513059907u)
												{
													if (num == 1642719936u)
													{
														if (localName == "Number")
														{
															illCalData.lightSourceData.Number = Convert.ToInt32(xmlNode4.Attributes[i].Value);
														}
													}
												}
												else if (localName == "CeilingFactor")
												{
													illCalData.roomData.CeilingFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
												}
											}
											else if (localName == "RoomTagID")
											{
												ElementId roomTagID = new ElementId(Convert.ToInt32(xmlNode4.Attributes[i].Value));
												illCalData.roomData.RoomTagID = roomTagID;
											}
										}
										else if (num <= 1997859497u)
										{
											if (num != 1868729652u)
											{
												if (num == 1997859497u)
												{
													if (localName == "BallastPower")
													{
														illCalData.lampData.BallastPower = Convert.ToDouble(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "LuminousFlux")
											{
												illCalData.lightSourceData.LuminousFlux = Convert.ToDouble(xmlNode4.Attributes[i].Value);
											}
										}
										else if (num != 2189814010u)
										{
											if (num != 2262998223u)
											{
												if (num == 2392788958u)
												{
													if (localName == "Spec")
													{
														illCalData.lampData.Spec = Convert.ToString(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "LuxResult")
											{
												illCalData.calResultData.Lux = Convert.ToDouble(xmlNode4.Attributes[i].Value);
											}
										}
										else if (localName == "Model")
										{
											illCalData.lightSourceData.Model = Convert.ToString(xmlNode4.Attributes[i].Value);
										}
									}
									else if (num <= 3089825177u)
									{
										if (num <= 2731542404u)
										{
											if (num <= 2630094352u)
											{
												if (num != 2434120127u)
												{
													if (num == 2630094352u)
													{
														if (localName == "CalState")
														{
															illCalData.roomData.CalState = (RoomCalState)Convert.ToInt32(xmlNode4.Attributes[i].Value);
														}
													}
												}
												else if (localName == "Lpd")
												{
													illCalData.roomData.Lpd = Convert.ToDouble(xmlNode4.Attributes[i].Value);
												}
											}
											else if (num != 2695953258u)
											{
												if (num == 2731542404u)
												{
													if (localName == "WallPerimeter")
													{
														illCalData.roomData.WallPerimeter = Convert.ToDouble(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "LightSourceType")
											{
												illCalData.lightSourceData.Type = Convert.ToString(xmlNode4.Attributes[i].Value);
											}
										}
										else if (num <= 2803669030u)
										{
											if (num != 2755897443u)
											{
												if (num == 2803669030u)
												{
													if (localName == "Lux")
													{
														illCalData.roomData.Lux = Convert.ToDouble(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "LampType")
											{
												illCalData.lampData.Type = Convert.ToString(xmlNode4.Attributes[i].Value);
											}
										}
										else if (num != 2976959527u)
										{
											if (num != 2994301137u)
											{
												if (num == 3089825177u)
												{
													if (localName == "RoomHeight")
													{
														illCalData.roomData.RoomHeight = Convert.ToDouble(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "LightSourceName")
											{
												illCalData.lightSourceData.Name = Convert.ToString(xmlNode4.Attributes[i].Value);
											}
										}
										else if (localName == "LuxChecked")
										{
											illCalData.calResultData.LuxChecked = (CheckedState)Convert.ToInt32(xmlNode4.Attributes[i].Value);
										}
									}
									else if (num <= 3511743878u)
									{
										if (num <= 3343492582u)
										{
											if (num != 3152175891u)
											{
												if (num == 3343492582u)
												{
													if (localName == "Power")
													{
														illCalData.lightSourceData.Power = Convert.ToDouble(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "WallUpFactor")
											{
												illCalData.roomData.WallUpFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
											}
										}
										else if (num != 3488416891u)
										{
											if (num != 3501683903u)
											{
												if (num == 3511743878u)
												{
													if (localName == "WallDownFactor")
													{
														illCalData.roomData.WallDownFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
													}
												}
											}
											else if (localName == "RoomArea")
											{
												illCalData.roomData.RoomArea = Convert.ToDouble(xmlNode4.Attributes[i].Value);
											}
										}
										else if (localName == "WorkHeight")
										{
											illCalData.roomData.WorkHeight = Convert.ToDouble(xmlNode4.Attributes[i].Value);
										}
									}
									else if (num <= 3576791974u)
									{
										if (num != 3565096770u)
										{
											if (num == 3576791974u)
											{
												if (localName == "LpdResult")
												{
													illCalData.calResultData.Lpd = Convert.ToDouble(xmlNode4.Attributes[i].Value);
												}
											}
										}
										else if (localName == "LpdEx")
										{
											illCalData.calResultData.LpdEx = Convert.ToDouble(xmlNode4.Attributes[i].Value);
										}
									}
									else if (num != 3764566595u)
									{
										if (num != 3879627329u)
										{
											if (num == 4274860424u)
											{
												if (localName == "LpdChecked")
												{
													illCalData.calResultData.LpdChecked = (CheckedState)Convert.ToInt32(xmlNode4.Attributes[i].Value);
												}
											}
										}
										else if (localName == "RoomName")
										{
											illCalData.roomData.RoomName = Convert.ToString(xmlNode4.Attributes[i].Value);
										}
									}
									else if (localName == "MaintenanceFactor")
									{
										illCalData.lampData.MaintenanceFactor = Convert.ToDouble(xmlNode4.Attributes[i].Value);
									}
								}
								dlgIllCalData.illCalDataSet.listIllCalData.Add(illCalData);
							}
						}
					}
				}
			}
			return true;
		}

		private void tsbWord_Click(object sender, EventArgs e)
		{
			List<IllCalData> list = new List<IllCalData>();
			WriteWord writeWord = new WriteWord();
			foreach (object obj in this.tabLevels.TabPages)
			{
				foreach (IllCalData item in (((TabPage)obj).Controls["DlgIllCalData"] as DlgIllCalData).illCalDataSet.listIllCalData)
				{
					list.Add(item);
				}
			}
			writeWord.IllCalDataSet = list;
			writeWord.Run();
		}

		protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
		{
			int num = 256;
			int num2 = 260;
			if ((msg.Msg == num | msg.Msg == num2) && keyData == Keys.Escape)
			{
				base.DialogResult = DialogResult.Cancel;
			}
			return false;
		}

		private UIApplication uiApp;

		private Document doc;

        private Autodesk.Revit.DB.View activeView;

		public int selectionMethod;
	}
}
